package com.garvin.gateway.system;

import com.garvin.gateway.service.GatewayRouteService;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.cloud.gateway.route.RouteDefinitionRepository;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * @author : garvin
 * @version V1.0
 * @date : 2020年07月06日 13:29
 */
@Component
public class JdbcRouteDefinitionRepository implements RouteDefinitionRepository {

    private GatewayRouteService gatewayRouteService;

    public JdbcRouteDefinitionRepository(GatewayRouteService gatewayRouteService) {
        this.gatewayRouteService = gatewayRouteService;
    }

    @Override
    public Flux<RouteDefinition> getRouteDefinitions() {
        return Flux.fromIterable(gatewayRouteService.getRouteDefinition());
    }

    @Override
    public Mono<Void> save(Mono<RouteDefinition> route) {
        return Mono.empty();
    }

    @Override
    public Mono<Void> delete(Mono<String> routeId) {
        return Mono.empty();
    }
}
